package cn.bzc.data.process.infra.log;

import org.apache.ibatis.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Mybatis 日志输出
 */
public class MybatisLogImpl implements Log {

    private final Logger sqlLog;

    private final Logger log;

    static final String PREFIX = "sqlLog.";

    public MybatisLogImpl(String clazz) {
        sqlLog = LoggerFactory.getLogger(PREFIX + clazz);
        log = LoggerFactory.getLogger(clazz);
    }

    @Override
    public boolean isDebugEnabled() {
        return true;
    }

    @Override
    public boolean isTraceEnabled() {
        return true;
    }

    @Override
    public void error(String s, Throwable e) {
        log.error(s, e);
    }

    @Override
    public void error(String s) {
        log.error(s);
    }

    @Override
    public void debug(String s) {
        sqlLog.debug(s);
    }

    @Override
    public void trace(String s) {
        sqlLog.trace(s);
    }

    @Override
    public void warn(String s) {
        log.warn(s);
    }
}
